//create gt-itm config file

#include<cstdio>
#include<cstdlib>
#include<ctime>

int uniform( int min, int max ){
	return (rand()%(max-min+1))+min;
}

int main( int argc, char** argv ){
	
	srand( time(0) );
	
	system( "rm -f SN/*" );

	int size;
	int min_processing;
	int max_processing;
	int min_bandwidth;
	int max_bandwidth;
	float prob_edge;
	
	sscanf( argv[1], "%d", &size );
	sscanf( argv[2], "%d", &min_processing );
	sscanf( argv[3], "%d", &max_processing );
	sscanf( argv[4], "%d", &min_bandwidth );
	sscanf( argv[5], "%d", &max_bandwidth );
	sscanf( argv[6], "%f", &prob_edge );

	FILE* out;

	out = fopen( "SN/sn_conf", "w" );
	if( !out ){
		printf( "Error in file generate_SN.cpp, function main: Could not open file SN/sn_conf\n" );
		exit(-1);
	}
	
	fprintf( out, "# <method keyword> <number of graphs> [<initial seed>]\n" );
	fprintf( out, "# <n> <scale> <edgemethod> <alpha> [<beta>] [<gamma>]\n" );
	fprintf( out, "geo 1 %d\n", rand() );
	fprintf( out, "%d 1000 3 %f\n", size, prob_edge );
	
	fclose( out );
	
	char cmd1[100];
	char cmd2[100];
	char cmd3[100];
	char cmd4[50];
	char cmd5[50];
	char cmd6[50];
	sprintf( cmd1, "./../softwares/gt-itm/bin/itm SN/sn_conf" );
	sprintf( cmd2, "./../softwares/gt-itm/bin/sgb2alt SN/sn_conf-0.gb SN/sn" );
	sprintf( cmd3, "./utils/convert_gt-itm_format SN/sn SN/sn.net %d %d %d %d %d %d", min_processing, max_processing, min_bandwidth, max_bandwidth, -1, rand() );
	sprintf( cmd4, "rm SN/sn_conf" );
	sprintf( cmd5, "rm SN/sn_conf-0.gb" );
	sprintf( cmd6, "rm SN/sn" );
	
	system( cmd1 );
	system( cmd2 );
	system( cmd3 );
	system( cmd4 );
	system( cmd5 );
	system( cmd6 );

}